package com.yonyou.cyxdms.sysAuth.service.controller.manage.log;


import com.yonyou.cyx.framework.controller.base.BaseController;
import com.yonyou.cyx.framework.util.bean.ApplicationContextHelper;
import com.yonyou.cyxdms.framework.bean.dto.user_info.LoginInfoDto;
import com.yonyou.cyxdms.sysAuth.service.service.log.OperateLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author maxingjian
 * @since 2019-10-21
 */
@Api(value = "操作日志", tags = {"操作日志"})
@RestController
@RequestMapping("/log")
public class OperateLogController extends BaseController {
    private final Logger logger = LoggerFactory.getLogger(OperateLogController.class);

    @Autowired
    public OperateLogService operateLogService;

    /**
     * 记录登录菜单
     *
     * @param:
     * @return:
     * @auther: maxingjian
     * @since: 2019/10/21
     */
    @GetMapping("/recordLog")
    @ApiImplicitParams({@ApiImplicitParam(value = "用户id", name = "userId", required = true, dataType = "string",
            paramType = "header")})
    public void recordLog(@ApiParam(name = "operateType", value = "日志类型", required = true) @RequestParam(value = "operateType") String operateType,
                          @ApiParam(name = "remark", value = "备注", required = false) @RequestParam(value = "remark", required = false, defaultValue = "") String remark,
                          @ApiParam(name = "operateContent", value = "操作日志", required = false) @RequestParam(value = "operateContent", required = false, defaultValue = "") String operateContent) {
        LoginInfoDto loginInfoDto = ApplicationContextHelper.getBeanByType(LoginInfoDto.class);
        operateLogService.recordLog(loginInfoDto, operateType, operateContent, remark);
    }
}